package gemini.basic.manager;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

public class ServerUtils {
	public static String getCauseStacktrace(Throwable cause) {
        String causeStack = null;
        
        StringWriter strWriter = null;
        try {
            strWriter = new StringWriter();
            cause.printStackTrace(new PrintWriter(strWriter));
            
            causeStack = strWriter.toString();
        } catch (Exception e) {
			System.out.println("Can not build up the cause stack trace:{" + e
					+ "}");
        } finally {
            if (strWriter != null) {
                try {
                    strWriter.close();
                } catch (IOException e) {
                	System.out.println("Can not close string write:{" + e
					+ "}");
                }
            }
        }
        
        return causeStack;
    }
}
